﻿using System.Data.Entity;
using Weapp.Data.Entities;
using Weapp.Data.Mappers;

namespace Weapp.Data
{
    public class WeappContext : DbContext
    {
        public WeappContext() : base("eWeappConnection")
        {
            Configuration.ProxyCreationEnabled = false;
            Configuration.LazyLoadingEnabled = false;

            Database.SetInitializer(
                new MigrateDatabaseToLatestVersion<WeappContext, WeappContextMigrationConfiguration>());
        }

        public DbSet<SizeCategory> SizeCategories { get; set; }
        public DbSet<Character> Characters { get; set; }
        public DbSet<UserDnD> Usuarios { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new SizeCategoryMapper());
            modelBuilder.Configurations.Add(new CharacterMapper());
            modelBuilder.Configurations.Add(new UserDnDMapper());

            base.OnModelCreating(modelBuilder);
        }
    }
}
